<template>
	<div id="">
		<van-row id="set_top">
			<van-col span="2" @click="goback">
				<van-icon name="arrow-left" />
			</van-col>
			<van-col span="8" offset="6">地址管理</van-col>
		</van-row>
		<!-- 地址管理布局 -->
		<van-address-list v-model="chosenAddressId" :list="list" default-tag-text="默认" @add="onAdd" @edit="onEdit" />
	</div>
</template>

<script>
	import {
		Toast
	} from 'vant';
	export default {
		data() {
			return {
				chosenAddressId: '1',
				list: []
			}
		},
		created() {
			const userInfo = JSON.parse(localStorage.getItem('login'))
			console.log(userInfo)
			this.$store.dispatch('user/vuexGetAddress', userInfo.member_id)
				.then(e => {
					this.list = e.data.data
					console.log(e, '地址')
				})
		},
		methods: {
			goback() {
				this.$router.go(-1)
			},
			onAdd() {
				Toast('新增地址');
			},
			onEdit(item, index) {
				Toast('编辑地址:' + index);
			},
		}
	}
</script>

<style>
	#set_top {
		font-size: 0.4rem;
		padding-top: 2vh;
		width: 96vw;
	}

	.van-button--danger {
		background: #000000;
		border: #000000;
	}
</style>
